﻿using MediatR;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Infrastructure.Interfaces;
using Traceability_Management.Read.Api.Application.Command.ProcessiingsWay;
using Traceability_Management.Read.Api.Application.Command.SlaughtsWay;

namespace Traceability_Management.Read.Api.Application.CommandHandler.ProcessiingsWay
{
    public class AddProcessiingsCommandHandler : IRequestHandler<AddProcessiingsCommand, ApiResult<int>>
    {
        IBaseReponsitory<Processiings> Processiings;

        public AddProcessiingsCommandHandler(IBaseReponsitory<Processiings> Processiings)
        {
            this.Processiings = Processiings;
        }

        public async Task<ApiResult<int>> Handle(AddProcessiingsCommand request, CancellationToken cancellationToken)
        {
            await Processiings.AddAsync(request.Processiings);
            return new ApiResult<int>
            {
                Code = ApiEnum.Success,
                Message = "添加成功",
                Data = 1
            };
        }
    }
}
